package ${package.Controller};

import com.mybatisplus.common.model.result.ResultBean;
import com.mybatisplus.common.model.param.ParamBean;
import com.mybatisplus.common.page.PageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import ${package.Service}.${table.serviceName};
import ${package.Entity}.${table.entityName};
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

import java.util.*;


@Slf4j
@RequestMapping("/${table.name}")
@RestController
<#if kotlin>
<#else>
public class ${table.controllerName} extends ${superControllerClass} {

    @Autowired
    private ${table.serviceName} ${table.name}Service;

    @ApiOperation("")
    @GetMapping("/queryList")
    public List<${table.entityName}> queryList() {
        List<${table.entityName}> queryList = ${table.name}Service.queryList();
        return queryList;
    }

    @ApiOperation("")
    @PutMapping("/changeById")
    public ResultBean<Boolean> changeById(@RequestBody ${table.entityName} ${table.name}) {
        Boolean flag = ${table.name}Service.changeById(${table.name});
        return ResultBean.createSuccess();
    }

    @ApiOperation("")
    @DeleteMapping("/remove/{id}")
    public ResultBean<Boolean> removeById(@PathVariable Long id) {
        Boolean flag = ${table.name}Service.removeById(id);
        return ResultBean.createSuccess();
    }

    @ApiOperation("")
    @PostMapping("/saveData")
    public ResultBean<Boolean> saveData(@RequestBody ${table.entityName} ${table.name}) {
        Boolean flag = ${table.name}Service.saveData(${table.name});
        return ResultBean.createSuccess();
    }

    @ApiOperation("")
    @PostMapping("/page")
        public ResultBean<PageVo> page(@RequestBody ParamBean<${table.entityName}> paramBean) {
        PageVo pageVo = ${table.name}Service.page(paramBean);
        return ResultBean.createSuccess(pageVo);
    }
}
</#if>